#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QFileDialog>
#include <QLabel>
#include <QLayout>
#include <QCloseEvent>
#include <QMessageBox>
#include <QPointer>
#include "countingtab.h"
#include "analysistab.h"
#include "detectiontab.h"
#include "germtab.h"
#include "imgproctab.h"
#include "informationcontrol.h"
#include "projectcreator.h"
#include "imgacquisitiontab.h"

using namespace cv;

namespace Ui
{
    class MainWindow;
}


//class QLabel;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void createProj();
    void openProj();
    bool save();
    bool closeProj();
    void updateStatusBar(const QString &curFile);
    void print();
    void count();
    void detect();
    void analyze();
    void inputDone(int result);
    void showTab(int tab);
    void about();
    void histgram();
    void doPCA();

private:
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();
    void createTabs();
    void pop(const QString& fileName);
    void restore();
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);
    void addToIcon(const QString &fileName);

    enum {MAXRecentFile = 5};

    QStringList recentFiles;
    QString curFile;
    QLabel *fileNameLabel;

    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *viewMenu;
    QMenu *toolsMenu;
    QMenu *windowMenu;
    QMenu *optionsMenu;
    QMenu *helpMenu;

    QAction *openAction;
    QAction *openProjAction;
    QAction *saveAction;
    QAction *closeAction;
    QAction *printAction;
    QAction *exitAction;
    QAction *countAction;
    QAction *detectAction;
    QAction *analyzeAction;
    QAction *aboutAction;
    QAction *histAction;
    QAction *pcaAction;

    QToolButton *newProj, *open;

    QPointer<CountingTab> countingTab;
    QPointer<DetectionTab> detectionTab;
    QPointer<AnalysisTab> analysisTab;
    QPointer<GermTab> germTab;
    QPointer<ImgProcTab> imgProcTab;
    QPointer<InformationControl> informationControl;
    QPointer<ImgAcquisitionTab> imgAcqTab;
    ProjectCreator* projectCreator;
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
